"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var BaseDao_1 = require('./BaseDao');
var GroupsDao = (function (_super) {
    __extends(GroupsDao, _super);
    function GroupsDao() {
        _super.call(this);
        this.groupModel = this.dbManager.getModel("mGroup");
    }
    GroupsDao.prototype.add = function (group, callback) {
        var group_ = new this.groupModel(group);
        group_.save(callback);
    };
    GroupsDao.prototype.update = function (group, callback) {
        var query = { _id: group._id };
        var updater = {
            "name": group.name,
            "description": group.description
        };
        this.groupModel.update(query, updater, callback);
    };
    GroupsDao.prototype.get = function (groupId, callback) {
        this.groupModel.findOne({ _id: groupId }).populate("project").exec(callback);
    };
    GroupsDao.prototype.gets = function (projectId, callback) {
        this.groupModel.find({ project: projectId }).populate("project").exec(callback);
    };
    GroupsDao.prototype.delete = function (groupId, callback) {
        this.groupModel.remove({ _id: groupId }).exec(callback);
    };
    return GroupsDao;
}(BaseDao_1.BaseDao));
exports.GroupsDao = GroupsDao;
